package tech.dongliang.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tech.dongliang.system.dao.SysRoleMenuDao;
import tech.dongliang.system.model.SysRoleMenu;
import tech.dongliang.system.service.ISysRoleMenuService;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xdzhang
 * @since 2019-01-18
 */
@Service
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuDao, SysRoleMenu> implements ISysRoleMenuService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveRoleMenu(Integer roleId, List<Integer> menuIds) {
        try {
            baseMapper.removeByRoleId(roleId);
            baseMapper.insertMenu(roleId, menuIds);
        } catch (Exception e) {
            return false;
        }
        return true;
    }
}
